import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../layout/Index.vue'
import Login from '../views/Login/index.vue'

import Dashboard from '../views/Dashboard'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: Index,
    children: [
      // 后台首页
      {
        path: '/dashboard',
        component: Dashboard
      },
      // 订单管理
      {
        path: '/orders',
        component: () =>
          import(/* webpackChunkName: "error" */ '../views/Orders')
      },
      // 商品管理
      {
        path: '/goods',
        component: () =>
          import(/* webpackChunkName: "goods" */ '../views/Goods'),
        children: [
          {
            path: '/goods/List',
            component: () =>
              import(/* webpackChunkName: "goods" */ '../views/Goods/List.vue')
          },
          {
            path: '/goods/add',
            component: () =>
              import(/* webpackChunkName: "goods" */ '../views/Goods/Add.vue')
          },
          {
            path: '/goods/cate',
            component: () =>
              import(/* webpackChunkName: "goods" */ '../views/Goods/Cate.vue')
          }
        ]
      },
      // 店铺管理
      {
        path: '/store',
        component: () =>
          import(/* webpackChunkName: "store" */ '../views/Store')
      },
      // 账号管理
      {
        path: '/account',
        component: () =>
          import(/* webpackChunkName: "account" */ '../views/Account/index.vue'),
        children: [
          {
            path: '/account/List',
            component: () =>
              import(/* webpackChunkName: "account" */ '../views/Account/List.vue')
          },
          {
            path: '/account/add',
            component: () =>
              import(/* webpackChunkName: "account" */ '../views/Account/AddPwd.vue')
          },
          {
            path: '/account/reset',
            component: () =>
              import(/* webpackChunkName: "account" */ '../views/Account/Reset.vue')
          }
        ]
      },
      // 销售统计
      {
        path: '/count',
        component: () =>
          import(/* webpackChunkName: "count" */ '../views/Count'),
        children: [
          {
            path: '/count/goods',
            component: () =>
              import(/* webpackChunkName: "count" */ '../views/Count/Goods.vue')
          },
          {
            path: '/count/orders',
            component: () =>
              import(/* webpackChunkName: "count" */ '../views/Count/Orders.vue')
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '*',
    redirect: '/404'
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "error" */ '../views/Error')
  }
]

// component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')

const router = new VueRouter({
  routes
})

export default router
